package com.yao.configration;

import com.yao.intercepter.MyIntercepter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class IntercepterConfig implements WebMvcConfigurer {

    private static final Logger log = LoggerFactory.getLogger(IntercepterConfig.class);

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("自定义拦截器开始加载...");
        registry.addInterceptor(new MyIntercepter())
                //TODO
                .addPathPatterns("/order/**")
                .addPathPatterns("/weixin/**")
                .addPathPatterns("/userAddress/**")
                .addPathPatterns("/cart/**")
                .excludePathPatterns("/weixin/wxLogin/*")
                .excludePathPatterns("/assets/**");
//                .excludePathPatterns("/**")
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
